package com.carbon.assets.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.carbon.assets.entity.CarbonExchange;
import com.carbon.assets.mapper.CarbonExchangeMapper;
import com.carbon.assets.service.CarbonExchangeService;
import com.carbon.assets.param.CarbonExchangeQueryParam;
import com.carbon.domain.assets.vo.CarbonExchangeQueryVo;
import com.carbon.common.service.BaseServiceImpl;
import com.carbon.common.api.Paging;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.io.Serializable;


/**
 * <p>
 * 碳交易所  服务实现类
 * </p>
 *
 * @author Li Jun
 * @since 2021-08-16
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class CarbonExchangeServiceImpl extends BaseServiceImpl<CarbonExchangeMapper, CarbonExchange> implements CarbonExchangeService {

    @Resource
    private CarbonExchangeMapper carbonExchangeMapper;

    @Override
    public CarbonExchangeQueryVo getCarbonExchangeById(Serializable id) {
        CarbonExchange carbonExchange = carbonExchangeMapper.selectById(id);
        CarbonExchangeQueryVo carbonExchangeQueryVo = new CarbonExchangeQueryVo();
        BeanUtil.copyProperties(carbonExchange, carbonExchangeQueryVo);
        return carbonExchangeQueryVo;
    }

    @Override
    public Paging<CarbonExchangeQueryVo> getCarbonExchangePageList(CarbonExchangeQueryParam param) {
        IPage<CarbonExchangeQueryVo> iPage = carbonExchangeMapper.getCarbonExchangePageList(getPage(param), param);
        return new Paging<>(iPage);
    }
}
